import { loadStatus, loadType } from '../../api/parkLock.js';

const parklock = {
  state: {
    status:{},
    type:{}
  },
  mutations: {
    updateStatus:(state,status)=>{
      state.status = status;
    },
    updateType:(state,type)=>{
        state.type = type;
    }
  },
  actions: {
    loadStatus:(context)=> { 
      loadStatus().then(function(resp) {
        if (resp.errmsg === "ok") {
          console.log(resp);
          context.commit('updateStatus',resp.data);
        }
      }).catch(function(e) {          
        console.log(e);
      });
    },
    loadType:(context)=> { 
        loadType().then(function(resp) {
          if (resp.errmsg === "ok") {
            console.log(resp);
            context.commit('updateType',resp.data);
          }
        }).catch(function(e) {          
          console.log(e);
        });
    }
  }
}

export default parklock
